home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / fgl110c.zip / 10-04.C < prev    next >
Text File  |  1992-01-31  |  2KB  |  69 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. #define VISUAL 0
  8. #define HIDDEN 1
  9.  
  10. int xmin[] = {  0, 96,192,  0, 96,192,  0, 96,192,  0, 96,192};
  11. int ymax[] = { 49, 49, 49, 99, 99, 99,149,149,149,199,199,199};
  12.  
  13. void main()
  14. {
  15.    int new_mode, old_mode;
  16.    int frame, offset;
  17.    int i, x, y;
  18.  
  19.    /* initialize the video environment */
  20.  
  21.    new_mode = fg_bestmode(320,200,2);
  22.    if (new_mode < 0 || new_mode == 12) {
  23.       printf("This program requires a 320 ");
  24.       printf("x 200 color graphics mode.\n");
  25.       exit(1);
  26.       }
  27.    old_mode = fg_getmode();
  28.    fg_setmode(new_mode);
  29.    fg_allocate(HIDDEN);
  30.  
  31.    /* draw the background in the upper left corner */
  32.  
  33.    fg_setpage(HIDDEN);
  34.    fg_setcolor(1);
  35.    fg_rect(0,95,0,49);
  36.    fg_setcolor(15);
  37.    fg_move(48,25);
  38.    fg_ellipse(20,20);
  39.  
  40.    /* display the animated object against each background */
  41.  
  42.    fg_setcolor(10);
  43.    offset = -10;
  44.    for (i = 1; i < 12; i++) {
  45.       x = xmin[i];
  46.       y = ymax[i];
  47.       fg_transfer(0,95,0,49,x,y,HIDDEN,HIDDEN);
  48.       fg_setclip(x,x+95,0,199);
  49.       fg_clprect(x+offset,x+offset+19,y-29,y-20);
  50.       offset += 10;
  51.       }
  52.  
  53.    /* slide the object across the background three times */
  54.  
  55.    for (i = 0; i < 36; i++) {
  56.       frame = i % 12;
  57.       x = xmin[frame];
  58.       y = ymax[frame];
  59.       fg_transfer(x,x+95,y-49,y,112,124,HIDDEN,VISUAL);
  60.       fg_waitfor(2);
  61.       }
  62.  
  63.    /* restore the original video mode and return to DOS */
  64.  
  65.    fg_freepage(HIDDEN);
  66.    fg_setmode(old_mode);
  67.    fg_reset();
  68. }
  69.